package controller.comparator;

import java.util.Comparator;

import entity.Section;

public class SectionComparatorByCourseCodeAndSectionCode implements Comparator<Section> {

	@Override
	public int compare(Section section, Section anotherSection) {
		int k = 0;
		/*
		 * Compare course code in ascending order
		 */
		String courseCode = section.getCourse().getCourseCode();
		String anotherCourseCode = anotherSection.getCourse()
				.getCourseCode();
		k = AlphanumComparator.compareTo(courseCode, anotherCourseCode);
		if (k != 0) {
			return k;
		}

		/*
		 * Compare section code in ascending order
		 */
		String sectionCode = section.getSectionCode();
		String anotherSectionCode = anotherSection.getSectionCode();
		k = AlphanumComparator.compareTo(sectionCode, anotherSectionCode);
		return k;
	
	}

}
